/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (Timer Classes)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/
#include "CTimer.h"

CTimer::CTimer ( TimerCallback CallBack, unsigned int ms, int repeat, int value ) 
{
	this->CallBack = CallBack;
	this->ms = ms;
	this->repeat = repeat;
	this->value = value;
	this->ticked = 0;
	this->startTick = clock();
}

CTimer::~CTimer ( void )
{
}

void CTimer::Tick ()
{
	ticked++;
	CallBack ( ticked, this->value );
}

int CTimer::getTimeUntilTick()
{
	int currMS = clock();
	int targetMS = this->startTick + this->ms;

	return targetMS - currMS;
}